
import java.util.Iterator;

public class Subset {

   public static void main(String[] args)
   {
      int k = Integer.parseInt(args[0]);
      RandomizedQueue<String> rqs = new RandomizedQueue<String>();

      while (!StdIn.isEmpty())
      {
         rqs.enqueue(StdIn.readString());
      }

      Iterator<String> iterator = rqs.iterator();

      for (int i = 0; i < k; i++)
      {
         System.out.println(iterator.next());
      }
   }
}
